﻿using System;
using System.Xml.Serialization;

namespace DivShare
{
    /// <summary>
    /// Provides a general response from DivShare server. This is an <c>abstract</c> class.
    /// </summary>
    [Serializable]
    [XmlRoot(ElementName = "response")]
    public abstract class GeneralResponse
    {
        /// <summary>
        /// Gets or sets the status code.
        /// </summary>
        /// <value>The status code.</value>
        [XmlAttribute(AttributeName = "status")]
        public int StatusCode { get; set; }

        /// <summary>
        /// Gets or sets the error message.
        /// </summary>
        /// <value>The error message.</value>
        [XmlElement(ElementName = "error")]
        public string ErrorMessage { get; set; }

        /// <summary>
        /// Gets a value indicating whether response is successful.
        /// </summary>
        /// <value><c>true</c> if successful; otherwise, <c>false</c>.</value>
        [XmlIgnore]
        public bool Success
        {
            get { return StatusCode > 0; }
        }

    }
}
